//+--------------------------------------------------------------------
//| Copyright(c) 2012 - an.vuongngocduy					
//| This file is a part of Compact Game Engine (CGE)	
//+--------------------------------------------------------------------
#ifndef __CGE_FILESTREAM_H__
#define __CGE_FILESTREAM_H__

#include <stdio.h>
#include "cgeEnums.h"
#include "cgeStream.h"
#include "cgeString.h"

namespace cge
{
	/// Provide interface to read/write data from file as input/output stream
	namespace io
	{
		class FileStream : public Stream
		{
		public:
			FileStream(const c8* filePath, EFileOpenMode mode);

			~FileStream();

			operator Stream&() const;

		protected:
			virtual b8 finalize();

			virtual u32 size() const;
			
			virtual u32 position() const;

			virtual u32 read(u8* dst, u32 count); 
			
			virtual u32 write(u8* src, u32 count);
	
			virtual b8 seek(u32 offset, b8 fromBeginning);

		protected:			
			FILE* mFile;
			u32 mFileSize;
			EFileOpenMode mMode;
		};
	}
}

#endif//__CGE_FLESTREAM_H__